// 存储路由的vuex

//临时内容
import {getnavigationList} from '@/api/head'
import router  from "@/router"
const state = {
    //当前路由标标志
    pagemark: null,
    //导航栏路由
    navigationList: [],
}
const actions = {
    axiosGetNavigationList(context) {
        //向后台请求导航栏路由  由head组件下navigation组件调用
        getnavigationList().then(navigationList => {
            // console.log(navigationList)
            context.commit('setNavigationList', navigationList)
        })
    },
}
const mutations = {
    setNavigationList(state,navigationList){
        state.navigationList=navigationList;
        //添加路由到router
       for(let nav of state.navigationList){
         router.addRoute(nav )
       }
     
    },
    setPagemark(state, mark) {
        state.pagemark = mark
    }
}
const getters = {

}


export default {
    namespaced: true,
    state,
    actions,
    getters,
    mutations
}